<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>元素选择器遗漏内容补充</title>
</head>
<body>
    <div class="main">
        <main>
            <div class="left"></div>
            <div class="right"></div>
        </main>
    </div>
    <div class="main2">
        <div class="left"></div>
    </div>
    <script>
        //通过parentElement选择父级元素
        //在元素选择结果的基础上可以继续执行元素选择操作(选择只针对当前标签)
        var main1 = document.querySelector('.main')
        var main2 = document.querySelector('.main2')
        console.log(main1.parentElement)//body
        console.log(main2.parentElement)//body
        console.log(main1.querySelector('.left').parentElement)//main
        console.log(main2.querySelector('.left').parentElement)//class='main2'的div
    </script>
</body>
</html>